home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / serial / dcon0.000 / dcon0 / dcon0.96 / tst.scr < prev   
Text File  |  1996-07-20  |  4KB  |  160 lines

  1. # dcon script to exercise it.
  2. goto testgoto
  3. print "Goto doesn't work!!!\n"
  4. exit 1
  5. :testgoto
  6. goto forward
  7. :backabit
  8. goto continue
  9. :forward
  10. goto backabit
  11. :continue
  12. goto ok
  13. :error
  14. print " error!\n"
  15. print "Strings:\n"
  16. print "$a: ",$a,"\n"
  17. print "$b: ",$b,"\n"
  18. print "$c: ",$c,"\n"
  19. print "$d: ",$d,"\n"
  20. print "$e: ",$e,"\n"
  21. print "$f: ",$f,"\n"
  22. print "$g: ",$g,"\n"
  23. print "$h: ",$h,"\n"
  24. exit 1
  25. :back
  26. goto ok3
  27. :routine2
  28. return
  29. :routine
  30. gosub routine2
  31. return
  32. :ok
  33. if 1=1 sleep 0 goto ok2
  34. print "Integer comparison or compound statements"
  35. goto error
  36. :ok2
  37. goto back
  38. :ok3
  39. gosub routine
  40. if 1=1 let a=0
  41. if 1=1 then let a=0
  42. else print "Else" goto error
  43. if 1=0 print "1=0" goto error
  44. else goto ok4
  45. print "Else" goto error
  46. :ok4
  47. let $a="Daniel Chouinard"
  48. let $b = 'Daniel Chouinard'
  49. let $f ="Daniel"+' '+"Chouinard"
  50. let $c='Dan'+$mid("abcdefghijklmnopqrstuvwxyz",8,1)+"el Chouinard"
  51. let $d="Daniel"
  52. let $e='Chouinard'
  53. let $d=$d+" "+$e
  54. let $e=$mid($d,0,6)+' '+$mid($d,7,9999)
  55. print "Current time: "+$mid($time(),11,8)+"\n"
  56. if "toto"!="toto" goto strerr
  57. if "toto"="tata" goto strerr
  58. if "toto"="toto" goto continue
  59. :strerr
  60. print "String Comparison"
  61. goto error
  62. :continue
  63. if "\r"!="^m" print "\\r != \^m" goto error
  64. if "\t"!="^i" print "\\t != \^i" goto error
  65. if '\n'!='^j' print "\\n != \^j" goto error
  66. if "\b"!="^h" print "\\b != \^h" goto error
  67. if "\032"!="^z" print "\\032 != \^z" goto error
  68. if "\134"!="\\" print "\\134 != \\" goto error
  69. if "aardvark" > "beatles" print "String Greater than" goto error
  70. if "beatrice" < "andrew" print "String less than" goto error
  71. if $a!=$b print "String Simple assignment" goto error
  72. if $a!=$f print "String Simple concatenation" goto error
  73. if $a!=$c print "String Simple $mid()" goto error
  74. if $a!=$d print "String replacement" goto error
  75. if $a!=$e print "$mid() went overboard" goto error
  76. print "All String tests Ok!\n"
  77. let a=1
  78. let b=2
  79. if b != b print "Integer comparison" goto error
  80. if a = b print "Integer comparison" goto error
  81. if a>b print "Integer greater than" goto error
  82. if b<a print "Integer less than" goto error
  83. if a!=a print "Integer not equal" goto error
  84. let a=time()
  85. sleep 1.2
  86. if time()=a print "time() or sleep" goto error
  87. hset 30
  88. let a=htime()
  89. print "hset 30 htime() returns ",a,"\n"
  90. if a<25 print "hset or htime()" goto error
  91. if a>45 print "hset or htime()" goto error
  92. sleep 0.3
  93. hset 0
  94. sleep 0.01
  95. let a=htime()
  96. print "0.01 second sleep measured ",a,"/100th of a second.\n"
  97. sleep 0.3
  98. hset 0
  99. sleep 0.1
  100. let a=htime()
  101. print "0.1 second sleep measured ",a,"/100th of a second.\n"
  102. sleep 0.3
  103. hset 0
  104. sleep 0.5
  105. let a=htime()
  106. print "0.5 second sleep measured ",a,"/100th of a second.\n"
  107. sleep 0.3
  108. hset 0
  109. sleep 1
  110. let a=htime()
  111. print "1 second sleep measured ",a,"/100th of a second. "
  112. if a<50 print " (too low)" goto error
  113. if a>200 print " (too high)" goto error
  114. print "\n"
  115. if len($a)!=16 print "len()" goto error
  116. if val("245")!=245 print "val()" goto error
  117. let $h=$rpipe("date")
  118. print '$rpipe("date")="',$h,'"\n'
  119. let a=len($time())
  120. if a!=24 print "$time() returned a ",a," character string" goto error
  121. print '$time()="',$time(),'"\n'
  122. putenv "DCTEST=This is a test"
  123. if % != 0 print "Could not putenv" goto error
  124. if $env("DCTEST")!="This is a test" print "putenv & env do not agree" goto error
  125. let $g=$rpipe("/bin/echo $DCTEST")
  126. if $g!="This is a test" print "putenv didn't export" goto error
  127. let $i="542"
  128. if val($i)!=542 print "val()" goto error
  129. if atol($i)!=542 print "atol()" goto error
  130. if $ltoa(atol($ltoa(atol($i))))!=$i print "$ltoa(atol())" goto error
  131. if 42&27 != 10 print "& (and operator)" goto error
  132. if 42|27 != 59 print "| (or operator)" goto error
  133. if 42^27 != 49 print "\^ (xor operator)" goto error
  134. if 2+2!=4 print "Simple addition" goto error
  135. if 5-3-1 = 3 print "Warning: This version of dcon has the brain-dead getvalue()!\n"
  136. if 5-3-1 = 1 print "This version of dcon has a better getvalue()\n"
  137. if 5-(3-1) != 3 print "Getvalue()" goto error
  138. if (5-3)-1 != 1 print "Getvalue()" goto error
  139. fork
  140. let p=%
  141. if p = -1 print "fork" goto error
  142. if p = 0 sleep 1 print "Child: Terminating.\n" sleep 0.5 exit 0
  143. sleep 0.5 print "Parent: Waiting for child to terminate...\n"
  144. wait
  145. if % != p print "Parent: Wait terminated with the wrong process number!"
  146. else print "Parent: child terminated.\n"
  147. :ftest
  148. let $k="/tmp/dcon.toto"
  149. system "rm -f "+$k
  150. let $j="This is dcon writing to a file."
  151. open file $k
  152. fprint $j,"\n"
  153. close file
  154. let $l=$rpipe("cat -s "+$k)
  155. if $j!=$l print "system(), open file, or fprint" goto error
  156. system "rm -f "+$k
  157. print "All tests ran fine.\n"
  158. exit 0
  159.  
  160.